package com.itheima.ydd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.ydd.pojo.SysMenu;
import com.itheima.ydd.pojo.SysRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.awt.*;
import java.util.List;

@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {
    @Select("select t3.* from sys_role t1 " +
            "join sys_role_menu t2 " +
            "on t1.id = t2.role_id " +
            "join sys_menu t3 " +
            "on t2.menu_id = t3.id " +
            "where t3.pid = 0 " +
            "and t1.id = #{id}")
    List<SysMenu> selectParentList(String id);
    @Select("select t2.* from sys_role_menu t1 " +
            "join sys_menu t2 " +
            "on t1.menu_id = t2.id " +
            "where t2.pid = #{id} " +
            "and t1.role_id = #{roleId}")
    List<SysMenu> selectChildList(@Param("roleId") String roleId, @Param("id") Integer id);
}
